import { ApiActionType } from "@/types/data";
import { RootThunkAction } from "@/types/store";
import request from "@/utils/request";




/**
 * 获取文章列表
 * @param channel_id 获取文章列表
 * @param timestamp 时间戳
 * @returns
 */
export const getArticlelist = (channel_id:number,timestamp:string):RootThunkAction =>{
return async(dispatch)=>{
const res= await request.get<ApiActionType<{pre_timestamp:string,results:[]}>>('/articles',{params:{channel_id,timestamp}})
// console.log(res.data.data.results,'55555');
const {pre_timestamp,results} = res.data.data
dispatch({
    type:'article/get_list',
    payload:{
        channel_id,
        timestamp:pre_timestamp,
        articles:results
    }
})
}
}
// export const getNewArticlelist = (channel_id:number,timestamp:string):RootThunkAction =>{
// return async(dispatch)=>{
// const res= await request.get<ApiActionType<{pre_timestamp:string,results:[]}>>('/articles',{params:{channel_id,timestamp}})
// // console.log(res.data.data.results,'55555');
// const {pre_timestamp,results} = res.data.data
// dispatch({
//     type:'article/addNew_list',
//     payload:{
//         channel_id,
//         timestamp:pre_timestamp,
//         articles:results
//     }
// })
// }
// }